import React from 'react'
import PropTypes from 'prop-types'
import ListItemText from '@material-ui/core/ListItemText';
import ListItem from '@material-ui/core/ListItem'

/**
 * 文本列表
 */
class TextOnlyListItem extends React.Component {
    state = {
        open: false,
    };
    handleClick = () => {
        this.setState(state => ({open: !state.open}));
    };
    render() {
        const {primary, secondary, inset, ...other } = this.props
        return (
            <React.Fragment>
                <ListItem {...other} onClick={this.handleClick}>
                    <ListItemText primary={primary} secondary={secondary} inset={inset}/>
                </ListItem>
                <NestedList open={this.state.open}>
                    {children}
                </NestedList>
            </React.Fragment>
        )
    }
}
TextOnlyListItem.propTypes = {
    primary: PropTypes.string.isRequired,
    secondary: PropTypes.string,
    dense: PropTypes.bool,
    classes: PropTypes.object,
    button:PropTypes.bool
}

export default TextOnlyListItem